<?php

namespace app\index\controller;

use think\response\Json;

class Ajax
{
    /**
     * @return \think\db\Query
     */
    public function join()
    {
        $post = input();
        if ($post['join_name']) {
            if ($post['join_phone']) {
                if ($post['join_age']) {
                    if (is_numeric($post['join_age'])) {
                        if (1 < $post['join_age'] and $post['join_age'] < 100) {
                            if ($post['join_card']) {
                                if (checkphone($post['join_phone'])) {
                                    if (checkcard($post['join_card'])) {
                                        //数据组装
                                        $add['join_name'] = space($post['join_name']);
                                        $add['join_phone'] = space($post['join_phone']);
                                        $add['join_age'] = space($post['join_age']);
                                        $add['join_card'] = space($post['join_card']);
                                        $add['join_time'] = time();
                                        $join = controller('data')->join($add);
                                        if ($join) {
                                            $return['mes'] = "报名成功";
                                            $return['status'] = 200;
                                        } else {
                                            $return['mes'] = "系统故障";
                                            $return['status'] = 401;
                                        }
                                    } else {
                                        $return['mes'] = "请输入合法的身份证号";
                                        $return['status'] = 404;
                                    }
                                } else {
                                    $return['mes'] = "请输入合法电话号码";
                                    $return['status'] = 404;
                                }
                            } else {
                                $return['mes'] = "请输入身份证号";
                                $return['status'] = 404;
                            }
                        } else {
                            $return['mes'] = "请输入合法年龄";
                            $return['status'] = 404;
                        }
                    } else {
                        $return['mes'] = "请输入合法年龄";
                        $return['status'] = 404;
                    }
                } else {
                    $return['mes'] = "请输入年龄";
                    $return['status'] = 404;
                }
            } else {
                $return['mes'] = "请输入电话";
                $return['status'] = 404;
            }
        } else {
            $return['mes'] = "请输入姓名";
            $return['status'] = 404;
        }
        return json($return);
    }



}